package com.aikon.wht.queue;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import java.util.PriorityQueue;

/**
 * @author haitao.wang
 */
public class TestOfPriorityQueue {

    public static void main(String[] args) {
        PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.comparing((p) -> p));
        pq.add(5);
        pq.add(300);
        pq.add(3);
        pq.add(200);
        pq.add(1);
        pq.add(100);
        pq.add(7);


        System.out.println(pq.size());
        System.out.println(pq.peek());
        System.out.println(pq.peek());
        System.out.println(pq.poll());
        System.out.println(pq.size());
        System.out.println(pq.poll());
        System.out.println(pq.size());
        System.out.println(pq.remove(100));
        System.out.println(pq.size());
        System.out.println(pq.poll());
        Iterator<Integer> iterator = pq.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        Object[] arrs = pq.toArray();
        System.out.println(Arrays.toString(arrs));
        Arrays.sort(arrs);
        System.out.println(Arrays.toString(arrs));


    }
}
